﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Reporting;
using Microsoft.ReportingServices;
using Microsoft.Reporting.WinForms;
using System.Data;

namespace Bluebunnie
{
    /// <summary>
    /// Interaction logic for ReportViewer.xaml
    /// </summary>
    public partial class ReportViewer : UserControl
    {
        private System.Windows.Forms.BindingSource ProductBindingSource;
        private System.ComponentModel.IContainer mform_components = null;
        string reportPath;

        public ReportViewer(object report)
        {
            InitializeComponent();
            //this.reportPath = reportPath;

            this.host.Child = (System.Windows.Forms.Control)report;

            //PrepareReport();
        }

        private void PrepareReport()
        {


            /*
             * this.viewer.LocalReport.ReportPath = reportPath;
            projectDataSet.tbl_itemDataTable table = new projectDataSet.tbl_itemDataTable();
            var rds = new ReportDataSource("ProjectDataSet", (DataTable)table);

            viewer.LocalReport.DataSources.Add(rds);
            viewer.RefreshReport();
             * 
            this.mform_components = new System.ComponentModel.Container();
            Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();

            this.ProductBindingSource = new System.Windows.Forms.BindingSource(this.mform_components);
            ((System.ComponentModel.ISupportInitialize)(this.ProductBindingSource)).BeginInit();

            reportDataSource1.Name = "WpfhostReportViewer_Product";
            reportDataSource1.Value = this.ProductBindingSource;

            this.viewer.LocalReport.DataSources.Add(reportDataSource1);
            this.viewer.LocalReport.ReportEmbeddedResource = string.Format("Bluebunnie.Reports.{0}", reportPath);
            this.viewer.Location = new System.Drawing.Point(89, 119);

            ((System.ComponentModel.ISupportInitialize)(this.ProductBindingSource)).EndInit();*/
        }  

    }
}
